<template>
  <!-- 消费对话框 -->
  <el-dialog :title="title" :visible.sync="visible" :close-on-click-modal="false" width="500px" append-to-body>
        <el-form ref="form" :model="form" label-width="80px">
        <el-form-item label="会员卡号" prop="memberNo">
            <el-input v-model="form.memberNo" :disabled="true"/>
        </el-form-item>
        <el-form-item label="姓名" prop="memberName">
            <el-input v-model="form.memberName" :disabled="true" />
        </el-form-item>
        <el-form-item label="手机号码" prop="phone">
            <el-input v-model="form.phone" :disabled="true" />
        </el-form-item>
        <el-form-item label="余额" prop="balanceAmount">
            <el-input v-model="form.balanceAmount" :disabled="true" />
        </el-form-item>
        <el-form-item label="消费金额" prop="amount">
            <el-input-number v-model="form.recordAmount"  size="medium" placeholder="请输入消费金额" />
        </el-form-item>
        <el-form-item label="消费类型" prop="consumeType">
            <el-select v-model="form.consumeType" allow-create placeholder="请选择消费类型">
            <el-option
                v-for="item in consumeTypeDic"
                :key="item.value"
                :label="item.label"
                :value="item.value">
            </el-option>
            </el-select>
        </el-form-item>
        <el-form-item label="备注" prop="remark">
            <el-input v-model="form.remark" type="textarea" placeholder="请输入备注" />
        </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
        </div>
    </el-dialog>
</template>

<script>
import { addRecord } from "@/api/system/record";
import mixin from '../mixin';
export default {
  mixins: [mixin],
  data() {
    return {
        form: {
            memberId: null,
            memberName: null,
            memberNo: null,
            phone: null,
            balanceAmount: null,
            consumeType: null,
            recordType: "1",
            recordAmount: 0,
            remark: null
        },
      consumeTypeDic: [{
          value: '剪发',
          label: '剪发'
      },{
          value: '洗头',
          label: '洗头'
      },]
    }
  },
  computed: {},
  mounted() {},
  methods: {
    initFormData (row) {
        this.form = {
            ...row,
            balanceAmount: row.memberBalanceAmount
        }
    },
    submitForm () {
        this.$refs["form"].validate(valid => {
        if (valid) {
          addRecord(this.consumeForm).then(response => {
            this.$modal.msgSuccess("消费成功");
            this.$emit('submit');
          });
        }
      });
    }
  }
}
</script>

